﻿namespace gixoom.Initiator.WcfWsHttp
{
    public interface IInitiatorBlockStorage
    {
        void OpenConnection();

        void CloseConnection();

        /// <summary>
        /// Stores the specified block in the storage.
        /// </summary>
        /// <param name="blockBytes">the block bytes</param>
        /// <returns>true if the block was successfully stored.</returns>
        /// <exception cref="System.ArgumentNullException"><i>blockBytes</i> is a null reference.</exception>
        bool StoreBlock(byte[] blockBytes);

        /// <summary>
        /// Retrieves block content by the specified array which represents the block id.
        /// </summary>
        /// <param name="blockId">the byte array which represents the block id</param>
        /// <returns>the content of the block by the specified block id or null if the block content
        /// cannot be retrieved</returns>
        /// <exception cref="System.ArgumentNullException"><i>blockIdBytes</i> is a null reference.</exception>
        byte[] RetrieveBlockContent(byte[] blockIdBytes);

        /// <summary>
        /// Checks whether the block with the specified block id exists.
        /// </summary>
        /// <param name="blockIdBytes">the block id to check existence of the block for</param>
        /// <returns>true if the block exists</returns>
        /// <exception cref="System.ArgumentNullException"><i>blockIdBytes</i> is a null reference.</exception>
        bool ExistsBlock(byte[] blockIdBytes);
    }
}
